<template>
  <div class="venus-list-page">
    <!--产品到期查询界面-->
    <div class="page-search">
      <el-row type="flex" justify="space-between" class="page-list-head">
        <div class="title">产品到期查询</div>
      </el-row>
      <el-row type="flex" class="search-list">
        <el-row type="flex" class="list-items">
          <div class="venus-input-box">
            <label>产品组合</label>
            <el-select
              v-model="table.prodExpire_table.port_code"
              class="venus-input-middle"
              filterable
              placeholder="请选择"
              @change="portfol_change_fnc">
              <el-option
                v-for="item in dict.t8_port_info_id"
                :key="item.value"
                :label="item.value + '-' + item.text"
                :value="item.value"
            />
            </el-select>
          </div>
          <div class="venus-input-box">
            <label>产品名称</label>
            <el-select
              v-model="table.prodExpire_table.prod_code"
              placeholder="请选择">
              <el-option
                v-for="item in dict.prod_code"
                :key="item.value"
                :label="item.value + '-' + item.text"
                :value="item.value"
              />
            </el-select>
          </div>
          <div class="venus-input-box">
            <label>到期日期</label>
            <el-date-picker
              v-model="table.prodExpire_table.v_start_date"
              type="date"
              class="venus-input-middle venus-input-date"
              placeholder="请输入起始日期"
              value-format="yyyyMMdd"
            /> -
            <el-date-picker
              v-model="table.prodExpire_table.v_end_date"
              type="date"
              class="venus-input-middle venus-input-date"
              placeholder="请输入截止日期"
              value-format="yyyyMMdd"
            />
          </div>
        </el-row>
        <!--      </el-row>-->
        <!--      <el-row type="flex" justify="end">-->

      </el-row>
      <el-row type="flex" class="list-items" justify="space-content">
        <div class="venus-btn-box">
          <el-button type="primary" @click="search">查询</el-button>
        </div>
        <div class="venus-btn-box">
          <el-button type="primary" @click="reset">重置</el-button>
        </div>
      </el-row>
    </div>
    <!--    查询列表返显-->
    <div class="page-list">
      <table-pagination
        :table-data="table.prodExpire_table.tableData"
        :table-header-config="table.tableHeaderConfig"
        highlight-current-row
        :total="table.prodExpire_table.total"
        :page-size="table.prodExpire_table.pageSize"
        :now-page="table.prodExpire_table.nowPage"
        :operation-config="table.prodExpire_table.operationConfig"
        :dict-data="dict"
        @current-change="currentChange"
      />
    </div>
    <!--提前兑付弹出框-->
    <el-dialog :title="dialog.dlgTilte" :visible.sync="dialog.dlgFormVisible">
      <!-- ref=dlgForm用于验证表单 -->
      <el-form ref="dlgForm" :model="dialog.form" size="mini">
        <el-row>
          <el-col :xs="0" :sm="0" :md="0">
            <el-input v-model="dialog.form.t8_prod_info_id" :disabled="true" type="hidden" />
            <el-input v-model="dialog.form.t8_sys_portfol_id" :disabled="true" type="hidden" />
            <el-input v-model="dialog.form.prod_type" :disabled="true" type="hidden" />
          </el-col>
          <el-col :xs="24" :sm="12" :md="12">
            <!-- prop,:rules必须一起写 -->
            <el-form-item
              label="产品组合代码"
              :label-width="dialog.dlgFormLabelWidth"
              prop="port_code"
            >
              <el-input v-model="dialog.form.port_code" disabled />
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="12" :md="12">
            <!-- prop,:rules必须一起写 -->
            <el-form-item
              label="产品代码"
              :label-width="dialog.dlgFormLabelWidth"
              prop="prod_code"
            >
              <el-input v-model="dialog.form.prod_code" disabled />
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="12" :md="12">
            <!-- prop,:rules必须一起写 -->
            <el-form-item
              label="产品名称"
              :label-width="dialog.dlgFormLabelWidth"
              prop="prod_name"
            >
              <el-input v-model="dialog.form.prod_name" disabled />
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="12" :md="12">
            <el-form-item
              label="产品模式"
              :label-width="dialog.dlgFormLabelWidth"
              prop="prod_mod"
            >
              <el-select
                v-model="dialog.form.prod_mod"
                placeholder="请选择产品模式"
                filterable
                clearable
                disabled
              >
                <el-option
                  v-for="(value,key,index) in dict.prod_mod"
                  :key="index"
                  :label="value"
                  :value="key"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="12" :md="12">
            <el-form-item
              label="核算方式"
              :label-width="dialog.dlgFormLabelWidth"
              prop="acct_mod"
            >
              <el-select
                v-model="dialog.form.acct_mod"
                placeholder="请选择核算方式"
                filterable
                clearable
                disabled
              >
                <el-option
                  v-for="(value,key,index) in dict.t8_busi_account_type"
                  :key="index"
                  :label="value"
                  :value="key"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="12" :md="12">
            <el-form-item
              label="计息基数"
              :label-width="dialog.dlgFormLabelWidth"
              prop="rate_base"
            >
              <el-select
                v-model="dialog.form.rate_base"
                placeholder="请选择计息基数"
                filterable
                clearable
                disabled
              >
                <el-option
                  v-for="(value,key,index) in dict.t8_intr_base"
                  :key="index"
                  :label="value"
                  :value="key"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="12" :md="12">
            <el-form-item
              label="产品成立日"
              :label-width="dialog.dlgFormLabelWidth"
              prop="establish_date"
            >
              <el-date-picker
                v-model="dialog.form.establish_date"
                type="date"
                class="venus-input-middle venus-input-date"
                placeholder="请输入日期"
                value-format="yyyyMMdd"
                disabled
              />
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="12" :md="12">
            <el-form-item
              label="收益起始日"
              :label-width="dialog.dlgFormLabelWidth"
              prop="start_fee_date"
            >
              <el-date-picker
                v-model="dialog.form.start_fee_date"
                type="date"
                class="venus-input-middle venus-input-date"
                placeholder="请输入日期"
                value-format="yyyyMMdd"
                disabled
              />
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="12" :md="12">
            <el-form-item
              label="产品到期日"
              :label-width="dialog.dlgFormLabelWidth"
              prop="end_date"
            >
              <el-date-picker
                v-model="dialog.form.end_date"
                type="date"
                class="venus-input-middle venus-input-date"
                placeholder="请输入日期"
                value-format="yyyyMMdd"
                disabled
              />
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="12" :md="12">
            <!-- prop,:rules必须一起写 -->
            <el-form-item
              label="产品实际期限(天)"
              :label-width="dialog.dlgFormLabelWidth"
              prop="real_days"
            >
              <el-input v-model="dialog.form.real_days" disabled />
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="12" :md="12">
            <el-form-item
              label="兑付日"
              :label-width="dialog.dlgFormLabelWidth"
              prop="pay_date"
            >
              <el-date-picker
                v-model="dialog.form.pay_date"
                type="date"
                class="venus-input-middle venus-input-date"
                placeholder="请输入日期"
                value-format="yyyyMMdd"
                disabled
              />
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="12" :md="12">
            <el-form-item
              label="本次付息起始日"
              :label-width="dialog.dlgFormLabelWidth"
              prop="pre_date"
            >
              <el-date-picker
                v-model="dialog.form.pre_intrday"
                type="date"
                class="venus-input-middle venus-input-date"
                placeholder="请输入日期"
                value-format="yyyyMMdd"
                disabled
              />
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="12" :md="12">
            <!-- prop,:rules必须一起写 -->
            <el-form-item
              label="本次收息期限(天)"
              :label-width="dialog.dlgFormLabelWidth"
              prop="charge_days"
            >
              <el-input v-model="dialog.form.charge_days" disabled />
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="12" :md="12">
            <!-- prop,:rules必须一起写 -->
            <el-form-item
              label="产品规模(元)"
              :label-width="dialog.dlgFormLabelWidth"
              prop="actual_scale"
            >
              <el-input v-model="dialog.form.actual_scale" type="number" disabled />
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="12" :md="12">
            <!-- prop,:rules必须一起写 -->
            <el-form-item
              label="产品余额(元)"
              :label-width="dialog.dlgFormLabelWidth"
              prop="balance"
            >
              <el-input v-model="dialog.form.balance" type="number" disabled />
            </el-form-item>
          </el-col>
          <!--封闭净值型-->
          <el-col :xs="24" :sm="12" :md="12" v-show="dialog.fbjz">
            <!-- prop,:rules必须一起写 -->
            <el-form-item
              label="兑付份额(份)"
              :label-width="dialog.dlgFormLabelWidth"
              prop="cash_vol"
            >
              <el-input v-model="dialog.form.cash_vol" type="number" disabled />
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="12" :md="12" v-show="dialog.fbjz">
            <!-- prop,:rules必须一起写 -->
            <el-form-item
              label="兑付净值"
              :label-width="dialog.dlgFormLabelWidth"
              prop="cash_net"
            >
              <el-input v-model="dialog.form.cash_net" type="number" disabled />
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="12" :md="12" v-show="dialog.fbjz">
            <!-- prop,:rules必须一起写 -->
            <el-form-item
              label="兑付金额(元)"
              :label-width="dialog.dlgFormLabelWidth"
              prop="cash_amt"
              :rules="dialog.formRules.cash_amt"
            >
              <el-input v-model="dialog.form.cash_amt" type="number" :disabled="dialog.dlgFormDisabled" />
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="12" :md="12" v-show="dialog.fbjz">
            <!-- prop,:rules必须一起写 -->
            <el-form-item
              label="到期净值"
              :label-width="dialog.dlgFormLabelWidth"
              prop="end_networth"
            >
              <el-input v-model="dialog.form.end_networth" type="number" disabled />
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="12" :md="12" v-show="dialog.fbjz">
            <!-- prop,:rules必须一起写 -->
            <el-form-item
              label="业绩报酬(元)"
              :label-width="dialog.dlgFormLabelWidth"
              prop="inv4"
              :rules="dialog.formRules.inv4"
            >
              <el-input v-model="dialog.form.inv4" type="number" :disabled="dialog.dlgFormDisabled" />
            </el-form-item>
          </el-col>
          <!--封闭非净值型-->
          <el-col :xs="24" :sm="12" :md="12" v-show="dialog.fbfjz">
            <!-- prop,:rules必须一起写 -->
            <el-form-item
              label="实付客户收益(元)"
              :label-width="dialog.dlgFormLabelWidth"
              prop="convert_income"
              :rules="dialog.formRules.convert_income"
            >
              <el-input v-model="dialog.form.convert_income" type="number" :disabled="dialog.dlgFormDisabled" />
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="12" :md="12" v-show="dialog.fbfjz">
            <!-- prop,:rules必须一起写 -->
            <el-form-item
              label="客户预期收益率(%)"
              :label-width="dialog.dlgFormLabelWidth"
              prop="expe_rate"
              :rules="dialog.formRules.expe_rate"
            >
              <el-input v-model="dialog.form.expe_rate" type="number" disabled />
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="12" :md="12" v-show="dialog.fbfjz">
            <!-- prop,:rules必须一起写 -->
            <el-form-item
              label="客户实际收益率(%)"
              :label-width="dialog.dlgFormLabelWidth"
              prop="real_rate"
              :rules="dialog.formRules.real_rate"
            >
              <el-input v-model="dialog.form.real_rate" type="number" :disabled="dialog.dlgFormDisabled" />
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="12" :md="12" v-show="dialog.fbfjz">
            <!-- prop,:rules必须一起写 -->
            <el-form-item
              label="实际投资收益(元)"
              :label-width="dialog.dlgFormLabelWidth"
              prop="invest_income"
              :rules="dialog.formRules.invest_income"
            >
              <el-input v-model="dialog.form.invest_income" type="number" :disabled="dialog.dlgFormDisabled" />
            </el-form-item>
          </el-col>
          <!--开放净值型-->
          <el-col :xs="24" :sm="12" :md="12" v-show="dialog.kfjz">
            <!-- prop,:rules必须一起写 -->
            <el-form-item
              label="兑付份额(份)"
              :label-width="dialog.dlgFormLabelWidth"
              prop="cash_vol"
              :rules="dialog.formRules.cash_vol"
            >
              <el-input v-model="dialog.form.cash_vol" type="number" disabled />
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="12" :md="12" v-show="dialog.kfjz">
            <!-- prop,:rules必须一起写 -->
            <el-form-item
              label="兑付净值"
              :label-width="dialog.dlgFormLabelWidth"
              prop="cash_net"
              :rules="dialog.formRules.cash_net"
            >
              <el-input v-model="dialog.form.cash_net" type="number" disabled />
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="12" :md="12" v-show="dialog.kfjz">
            <!-- prop,:rules必须一起写 -->
            <el-form-item
              label="兑付金额(元)"
              :label-width="dialog.dlgFormLabelWidth"
              prop="cash_amt"
              :rules="dialog.formRules.cash_amt"
            >
              <el-input v-model="dialog.form.cash_amt" type="number" :disabled="dialog.dlgFormDisabled" />
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="12" :md="12" v-show="dialog.kfjz">
            <!-- prop,:rules必须一起写 -->
            <el-form-item
              label="到期净值"
              :label-width="dialog.dlgFormLabelWidth"
              prop="end_networth"
              :rules="dialog.formRules.end_networth"
            >
              <el-input v-model="dialog.form.end_networth" type="number" disabled />
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="12" :md="12" v-show="dialog.kfjz">
            <!-- prop,:rules必须一起写 -->
            <el-form-item
              label="业绩报酬(元)"
              :label-width="dialog.dlgFormLabelWidth"
              prop="inv4"
              :rules="dialog.formRules.inv4"
            >
              <el-input v-model="dialog.form.inv4" type="number" :disabled="dialog.dlgFormDisabled" />
            </el-form-item>
          </el-col>
          <!--货币型-->
          <el-col :xs="24" :sm="12" :md="12" v-show="dialog.hbx">
            <!-- prop,:rules必须一起写 -->
            <el-form-item
              label="万份收益(元)"
              :label-width="dialog.dlgFormLabelWidth"
              prop="thousand_profit"
              :rules="dialog.formRules.thousand_profit"
            >
              <el-input v-model="dialog.form.thousand_profit" type="number" disabled />
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="12" :md="12" v-show="dialog.hbx">
            <!-- prop,:rules必须一起写 -->
            <el-form-item
              label="兑付份额(份)"
              :label-width="dialog.dlgFormLabelWidth"
              prop="cash_vol"
              :rules="dialog.formRules.cash_vol"
            >
              <el-input v-model="dialog.form.cash_vol" type="number" disabled />
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="12" :md="12" v-show="dialog.hbx">
            <!-- prop,:rules必须一起写 -->
            <el-form-item
              label="兑付金额(元)"
              :label-width="dialog.dlgFormLabelWidth"
              prop="cash_amt"
              :rules="dialog.formRules.cash_amt"
            >
              <el-input v-model="dialog.form.cash_amt" type="number" :disabled="dialog.dlgFormDisabled" />
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="12" :md="12" >
            <!-- prop,:rules必须一起写 -->
            <el-form-item
              label="浮动管理费(元)"
              :label-width="dialog.dlgFormLabelWidth"
              prop="fee_float"
              :rules="dialog.formRules.fee_float"
            >
              <el-input v-model="dialog.form.fee_float" type="number" :disabled="dialog.dlgFormDisabled" />
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div v-show="!dialog.dlgFormDisabled" slot="footer" class="dialog-footer" style="text-align: center">
        <el-button type="success" @click="popOk">确 定</el-button>
        <el-button type="info" plain @click="dialog.dlgFormVisible=false">取 消</el-button>
      </div>
      <div v-show="dialog.dlgFormDisabled" slot="footer" class="dialog-footer" style="text-align: center">
        <el-button type="info" plain @click="dialog.dlgFormVisible=false">关闭</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
  import request from '../../../../../utils/request'
  import * as kk from '../../../../../utils/k-utils'

  export default {
    name: 'ProdExpire',
    data() { // 数据定义
      return {
        /* 字典 */
        dict: {
          prod_mod: {},
          run_stat: {},
          t8_busi_account_type: {},
          t8_port_info_id: [], // 产品组合
          prod_code: [] // 产品名称
        },
        table: {
          tableHeaderConfig: [ // 表头配置
            { prop: 'port_name', label: '产品组合名称' },
            { prop: 'prod_name', label: '产品名称' },
            { prop: 'prod_mod', label: '产品模式' },
            { prop: 'establish_date', label: '收益起始日' },
            { prop: 'end_date', label: '产品清盘日' },
            { prop: 'actual_scale', label: '产品规模（元）' },
            { prop: 'expe_rate', label: '预期收益率（%）' },
            { prop: 'pay_date', label: '兑付日' },
            { prop: 'run_stat', label: '产品状态' }
          ],
          prodExpire_table: {
            limit: 5, // 分页配置
            total: 0, // 数据总条数
            nowPage: 1, // 当前页
            tableData: [], // 表格数据
            exeid: 'prodexpireES_001', // exeid
            operationConfig: { // 表格操作配置
              fixed: 'left',
              width: 200,
              operationButton: [
                // value:操作文字； func:回调函数
                { value: '产品到期', func: this.prodexpirepop },
                { value: '详情', func: this.prodExpireDeail }
              ]
            },
            // 以下是查询参数
            port_code: '',
            prod_code: '',
            v_start_date: '',
            v_end_date: ''
          }
        },
        /* ===========新增，修改，详情=============== */
        dialog: {
          dlgTilte: '标题',
          dlgFormVisible: false,
          dlgFormDisabled: true,
          fbjz: false, // 封闭净值型显示字段
          fbfjz: false, // 封闭非净值型显示字段
          kfjz: false, // 开放净值型显示字段
          hbx: false, // 货币型显示字段
          dlgFormLabelWidth: '160px',
          formRules: {
            cash_amt: [
              { required: true, message: '请输入兑付金额(元)', trigger: 'blur' }
            ],
            inv4: [
              { required: true, message: '请输入业绩报酬(元)', trigger: 'blur' }
            ],
            fee_float: [
              { required: true, message: '请输入浮动管理费(元)', trigger: 'blur' }
            ]
          },
          form: {
            t8_prod_info_id: '', // 产品id
            t8_sys_portfol_id: '', // 投组id
            port_code: '', // 产品组合代码
            prod_code: '', // 产品代码
            prod_type: '', // 产品类型
            prod_name: '', // 产品名称
            prod_mod: '', // 产品模式
            acct_mod: '', // 核算方式
            rate_base: '', // 计息基数
            establish_date: '', // 产品成立日
            start_fee_date: '', // 收益起始日
            end_date: '', // 产品到期日
            real_days: '', // 产品实际期限(天)
            pay_date: '', // 兑付日
            pre_intrday: '', // 本次付息起始日
            charge_days: '', // 本次收息期限(天)
            actual_scale: '', // 产品规模(元)
            balance: '', // 产品余额(元)
            formercashday: '', // 原兑付日
            cash_vol: '', // 兑付份额(份)
            cash_net: '', // 兑付净值
            cash_amt: '', // 兑付金额(元)
            end_networth: '', // 到期净值
            inv4: '', // 业绩报酬(元)
            fee_float: '', // 浮动管理费(元)
            real_rate: '', // 客户实际收益率(%)
            invest_income: '', // 实际投资收益(元)
            thousand_profit: '' // 万份收益(元)
          }
        }
      }
    },
    mounted() {
      // 初始化调用
      this.init()
    },
    methods: {
      init: function() {
        kk.k_load_dict(this, 'prod_mod', 't8_prod_model')
        kk.k_load_dict(this, 'run_stat', 't8_prod_state')
        kk.k_load_dict(this, 't8_busi_account_type', 't8_busi_account_type')
        this.load_dict_exeid(this, 'prod', 'prodInterestPayES_001', 't8_port_info_id')
        this.load_dict_exeid(this, 'prod', 'prodInterestPayES_002', 'prod_code')
        this.table.prodExpire_table.nowPage = 1
        kk.k_load_table(this, 'prodExpire_table', 'prod')
      },
      search() { // 查询函数
        this.table.prodExpire_table.nowPage = 1
        kk.k_load_table(this, 'prodExpire_table', 'prod')
      },
      reset() { // 重置函数
        this.table.prodExpire_table.port_code = ''
        this.table.prodExpire_table.prod_code = ''
        this.table.prodExpire_table.v_start_date = ''
        this.table.prodExpire_table.v_end_date = ''
      },
      // 下一页触发的事件
      currentChange(index) {
        this.table.prodExpire_table.nowPage = index
        kk.k_load_table(this, 'prodExpire_table', 'prod')
      },
      prodexpirepop(params) { // 产品到期函数
        this.dialog.dlgTilte = '产品到期'
        this.dialog.dlgFormDisabled = false // 是否禁用输入框
        this.dialog.dlgOkHandler = 'popOk' // 自己定义调用那个函数
        if(params.prod_mod == 5) { // 封闭净值型
          this.dialog.fbjz = true
          this.dialog.fbfjz = false
          this.dialog.kfjz = false
          this.dialog.hbx = false
        }
        else if (params.prod_mod == 2) { // 封闭非净值型
          this.dialog.fbfjz = true
          this.dialog.fbjz = false
          this.dialog.kfjz = false
          this.dialog.hbx = false
          params.real_rate = params.expe_rate
        }
        else if (params.prod_mod == 4) { // 开放净值型
          this.dialog.kfjz = true
          this.dialog.fbjz = false
          this.dialog.fbfjz = false
          this.dialog.hbx = false
        }
        else if (params.prod_mod == 6) { // 货币型
          this.dialog.hbx = true
          this.dialog.fbjz = false
          this.dialog.fbfjz = false
          this.dialog.kfjz = false
        }
        params.paraid = '80000010'
        request({
          loading: true,
          url: 'public/base/comn-query.json?exeid=M0000EQ003',
          method: 'post',
          params: params
        }).then(rep3 => {
          if(1 == rep3.rows[0].paravalue) {
            if(!isEmpty(rep3.returndata.cust_income)) {
              //兑付资金（利息）
              params.cust_income = rep3.returndata.cust_income
              params.convert_income = rep3.returndata.cust_income
            }
            if (!isEmpty(rep3.returndata.cust_vol)) {
              //兑付份额
              params.cust_vol = rep3.returndata.cust_vol
            }
            if (!isEmpty(rep3.returndata.nav)) {
              //兑付净值 (T-1)
              params.nav = rep3.returndata.nav
            }
            if (!isEmpty(rep3.returndata.performance_fee)) {
              //业绩报酬
              params.inv4 = rep3.returndata.performance_fee
            }
            if (!isEmpty(rep3.returndata.ack_date)) {
              //到期日/提前兑付日
              params.ack_date = rep3.returndata.ack_date
            }
          }
          // 查询付息起始日
          request({
            loading: true,
            url: 'prod/base/comn-query.json?exeid=prodexpirepreES_003',
            method: 'post',
            params: params
          }).then(rep => {
            params.pre_intrday = rep.rows[0].pre_date
            params.real_days = this.getDateRegion(params.pay_date, params.pre_intrday)
            params.charge_days = params.real_days
            request({
              loading: true,
              url: 'prod/base/comn-query.json?exeid=getBalance',
              method: 'post',
              params: params
            }).then(rep2 => {
              params.cash_vol = rep2.rows[0].cash_vol
              params.balance = rep2.rows[0].principalbln
              request({
                loading: true,
                url: 'prod/prod/getProdPue',
                method: 'post',
                params: params
              }).then(rep3 => {
                this.copyObj(params, this.dialog.form)
              })
            })
          })
        })
        this.dialog.dlgFormVisible = true
      },
      portfol_change_fnc(val) { // 选择了产品组合之后加载产品信息
        this.load_dict_exeid_byParams(this, 'prod', { t8_sys_portfol_id: val }, 'prodInterestPayES_002', 'prod_code')
      },
      prodExpireDeail(params) { // 详情函数
        this.prodexpirepop(params)
        this.dialog.dlgFormDisabled = true
      },
      /* 通过exeid加载字典 */
      load_dict_exeid(this_object, service_name, exeid, dict) {
        request({
          loading: true,
          url: service_name + '/base/comn-query.json?exeid=' + exeid,
          method: 'post'
        }).then(rep => {
          this_object['dict'][dict] = rep.rows
        })
      },
      /* 通过exeid加载字典 */
      load_dict_exeid_byParams(this_object, service_name, params, exeid, dict) {
        request({
          loading: true,
          url: service_name + '/base/comn-query.json?exeid=' + exeid,
          method: 'post',
          params: params
        }).then(rep => {
          this_object['dict'][dict] = rep.rows
        })
      },
      /*
       * 将obj1对象的数据拷贝到obj对象
       */
      copyObj(obj1, obj2) {
        for (var key in obj1) {
          if (key === '__proto__') {
            continue
          }
          obj2[key] = obj1[key]
        }
      },
      getDateRegion(beginDate, endDate) { // 日期相减
        if (beginDate != '' && endDate != '') {
          var aDate, oDate1, oDate2, iDays
          if(beginDate.length == 8){
            beginDate = beginDate.substr(0, 4) + '-' + beginDate.substr(4, 2) + '-' + beginDate.substr(6, 2)
          }
          if(endDate.length == 8){
            endDate = endDate.substr(0, 4) + '-' + endDate.substr(4,2) + '-' + endDate.substr(6, 2)
          }
          aDate = beginDate.split(" - ")
          oDate1 = new Date(aDate[1] + '/' + aDate[2] + '/' + aDate[0])
          aDate = endDate.split(" - ")
          oDate2 = new Date(aDate[1] + '/' + aDate[2] + '/' + aDate[0])
          var i = (oDate1 - oDate2) / 1000 / 60 / 60 / 24
          iDays = i
          return iDays
        } else{
          return 0
        }
      },
    }
  }
</script>

<style scoped>
</style>
